<?php
class ContactController extends Zend_Controller_Action {
	function init() {
		$this->view->action = $this->getRequest()->getControllerName();
		$this->view->headLink()->appendStylesheet("/css/contact.css");
		$this->view->headScript()->appendFile('/js/contact.js');
		$this->view->form = new ContactForm();
	}
	public function indexAction() {
	}
	public function sendAction() {
		$this->_helper->layout()->disableLayout();
		$contact = new Zend_Db_Table('contact');
		$request = $this->getRequest();
		if($request->isPost()) {
			$formData  = $request->getPost();
			if($this->view->form->isValid($formData)) {
				unset($formData['send']);
				$formData['ip'] = $_SERVER['REMOTE_ADDR'];
				$formData['browser'] = $_SERVER['HTTP_USER_AGENT'];
				$this->view->sent = $formData['sent'] = time();
				$contact->insert($formData);
			} else {
				$this->view->error = true;
			}
		}
	}
}